﻿@model IEnumerable<blacksoft.Models.Terminal>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

@if (TempData["create_success"] != null)
{
    <div class="success grid_12">
        <h3>Nuevo: @TempData["create_success"].</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}
else if (TempData["edit_success"] != null)
{
    <div class="success grid_12">
        <h3>Modificar: @TempData["edit_success"].</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}
else if (TempData["delete_success"] != null)
{
    <div class="success grid_12">
        <h3>Eliminar: @TempData["delete_success"].</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}

@if (TempData["create_failure"] != null)
{
    <div class="error grid_12">
        <h3>Nuevo: @TempData["create_failure"].</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}
else if (TempData["details_failure"] != null)
{
    <div class="error grid_12">
        <h3>Detalle: @TempData["details_failure"].</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}
else if (TempData["edit_failure"] != null)
{
    <div class="error grid_12">
        <h3>Modificar: @TempData["edit_failure"].</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}
else if (TempData["delete_failure"] != null)
{
    <div class="error grid_12">
        <h3>Eliminar: @TempData["delete_failure"].</h3>
        <a class="hide_btn" href="#"></a>
    </div>
}

<div class="block big">
    <div class="titlebar">
        <h3>Mantener Terminales</h3>
    </div>
    <div class="block_cont">
        <a href="/Terminal/Create" class="navbutton">
            <span class="icon_plus">
                Nueva Terminal
            </span>
        </a>
        <hr />
        @using (Html.BeginForm("Index", "Terminal", FormMethod.Get))
        {
            //Filtros
            <p>
                Nombre: @Html.TextBox("search_nombre", null, new { @class = "text-box single-line" })
                Dirección: @Html.TextBox("search_direccion", null, new { @class = "text-box single-line" })
                Departamento: @Html.DropDownList("search_departamento", null, "Todos", new { @class = "select" })
                Teléfono: @Html.DropDownList("search_telefono", null, "Todos", new { @class = "select" })
                E-mail: @Html.TextBox("search_email", null, new { @class = "text-box single-line" })
                Estado: @Html.DropDownList("search_estado", null, "Todos", new { @class = "select" })
                <input type="submit" value="Filtrar" class="btn btn-default" style="margin-top: 10px;" />
            </p>
        }
        <hr />
        <table class="data-table">
            <thead>
                <tr>
                    <th>
                        @Html.DisplayNameFor(model => model.Nombre)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.Direccion)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.Provincia)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.Departamento)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.Telefono)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.Email)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.Estado)
                    </th>
                    <th>
                        Acciones
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.Nombre)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Direccion)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Provincia)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Departamento)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Telefono)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Email)
                        </td>
                        <td>                            
                            @if (item.Estado == "AC")
                            {
                                @Html.Display("EstadoAC")
                            }
                            else if (item.Estado == "IN")
                            {
                                @Html.Display("EstadoIN")
                            }
                            else if (item.Estado == "AN")
                            {
                                @Html.Display("EstadoAN")
                            }
                        </td>
                        <td>
                            <div style="height: 3px;"></div>
                            <div class="actionbar">
                                <a href=@string.Concat("/Terminal/Details/", item.IDTerminal) class="action view"><span>Detalles</span></a>
                                <a href=@string.Concat("/Terminal/Edit/", item.IDTerminal) class="action edit"><span>Modificar</span></a>
                                <a href=@string.Concat("/Terminal/Delete/", item.IDTerminal) class="action delete"><span>Eliminar</span></a>
                            </div>
                        </td>
                    </tr>
                }
            </tbody>
            

        </table>
    </div>
</div> 




